#include <bits/stdc++.h>

#define N 100050

using namespace std;

int A, B, C;

int T, n, m, L, V;
struct car{
	int d, v, a;
} a[N];
int p[N];

inline int judge(int Vn, int vn, int an) {return max(0, (Vn * Vn - vn * vn) / an / 2) + 1;}

int main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	
	cin >> T;
	while(T--){
		A = B = C = 1;
		
		cin >> n >> m >> L >> V;
		memset(a, 0, sizeof a);
		memset(p, 0, sizeof p);
		for(int i = 1; i <= n; i++){
			cin >> a[i].d >> a[i].v >> a[i].a;
			if(a[i].a != 0) A = 0;
			if(a[i].a <= 0) B = 0;
			if(a[i].a >= 0) C = 0;
		}
		for(int i = 1; i <= m; i++) cin >> p[i];
		
		if(A == 1){
			int ans = 0, rem = m;
			for(int i = 1; i <= n; i++)
				if(a[i].v > V && a[i].d <= p[m]) ans++;
			if(ans > 0) rem = m - 1;
			cout << ans << " " << rem << "\n";
		}
		if(B == 1){
			int ans = 0, rem = m;
			
			for(int i = 1; i <= n; i++){
				if(a[i].v > V && a[i].d <= p[m]) {ans++; continue;}
				int d = judge(V, a[i].v, a[i].a);
				if(a[i].d + d <= p[m]) ans++;
			}
			if(ans > 0) rem = m - 1;
			cout << ans << " " << rem << "\n";
		}
		if(C == 1){
			vector <pair <int , int> > b;
			int ans = 0, rem = 0;
			
			for(int i = 1; i <= n; i++){
				int d = -((V * V - a[i].v * a[i].v) / a[i].a / 2);
				int l = a[i].d, r = a[i].d + d;
				int L = 1, R = m;
				int ll, rr;
				while(L <= R){
					int mid = (L + R) >> 1;
					if(p[mid] >= l){ll = mid, R = mid - 1;}
					else L = mid + 1;
				}
				L = 1, R = m;
				while(L <= R){
					int mid = (L + R) >> 1;
					if(p[mid] <= r){rr = mid, L = mid + 1;}
					else R = mid - 1;
				}
				if(ll > rr && a[i].v >= V) continue;
				ans++;
				pair <int, int> tmp = make_pair(ll, rr);
				int f = 0;
				for(auto k : b){
					if(k.first <= tmp.second && k.second >= tmp.first){
						f = 1;
						break;
					}
				}
				if(f == 0) rem++;
				b.push_back(tmp);
			}
			cout << ans << " " << m - rem << "\n";
		}
		if(A == 0 && B == 0 && C == 0) cout << 3 << " " << 3 << "\n";
	}
	
	return 0;
}
